﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

namespace Gollie.Controls
{
	public partial class VendorPresenter : BaseUserControl
	{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

		protected override void PreLoadHandler(object sender, EventArgs e)
		{
			this.Initialize();
			
		}

		private void Initialize()
		{
			this.SetVendor();

			if (string.IsNullOrEmpty(this.Website))
			{
				this.pnlNoHref.ToolTip = this.Street + "|" + this.City;
				this.pnlHref.Visible = false;
				//this.lblBedrijfsnaamNo.Text = this.Bedrijfsnaam;
				//this.lblPlaatsNo.Text = this.City;
				////this.lblStraatNo.Text = this.Street;
			}
			else
			{
				this.pnlHref.ToolTip = this.Street + "|" + this.City + "|" + this.Website;
				this.pnlNoHref.Visible = false;

				this.hplWebsite.NavigateUrl = this.Website;

				//this.lblBedrijfsnaam.Text = this.Bedrijfsnaam;
				//this.lblPlaats.Text = this.City;
				////this.lblStraat.Text = this.Street;
			}
		}

		private void SetVendor()
		{
			VendorInfo vendor = new VendorInfo((uint)this.VendorId);

			string path = UseXXSmall ? vendor.LogoXXSmallPath : vendor.LogoSmallPath;

			if (string.IsNullOrEmpty(path))
			{
				this.ImageRenderer.Visible = false;
				this.ImageRendererNo.Visible = false;
			}
			else
			{
				this.ImageRendererNo.ImagePath = path;
				this.ImageRenderer.ImagePath = path;
			}
		}

		public string Bedrijfsnaam
		{
			get;
			set;
		}

		public int VendorId
		{
			get;
			set;
		}

		public string Website
		{
			get;
			set;
		}

		public string Street
		{
			get;
			set;
		}

		public string City
		{
			get;
			set;
		}

		public bool UseXXSmall
		{
			get;
			set;
		}
	}
}